What is PyTorch?

PyTorch is a Python based scientific computing package.

PyTorch replace NumPy using the power of GPUs.

PyTorch is a deep learning research platform that provides flexibility and speed.

Getting Started

Tensors

Tensors are similar to NumPy’s ndarrays with the addition being that Tensors can also be used on a GPU to accelerate computing.

from__future__import print_function
import torch

Construct a 5x3 matrix, uninitialized:

x= torch.Tensor(5, 3)
print(x)

Out:

0.0000e+00 0.0000e+00 5.1715e+36
4.5759e-41  5.1720e+36  4.5759e-41
 1.6410e+38  4.5759e-41  1.6410e+38
 4.5759e-41  2.0297e+38  4.5759e-41
 1.9567e+38  4.5759e-41 -2.9502e-12
[torch.FloatTensor of size 5x3]

Construct a randomly initialized matrix:

x=torch.rand(5,3)
print(x)

results matching ""

    No results matching ""